package com.xand.bt.market;

import java.util.HashMap;
import java.util.Map;

import com.xand.bt.api.MarketImageChangeNotify;

public class MarketStoresManager {

	private static MarketStoresManager instance;
	
	private Map<String, MarketStore> markets;
	
	public static MarketStoresManager getInstance() {
		if(instance == null)
			instance = new MarketStoresManager();
		
		return instance;
	}
	
	private MarketStoresManager() {
		this.markets = new HashMap<String, MarketStore>();
	}
	
	public void notifyMarketImageChange(MarketImageChangeNotify change) {
		String marketLabel = change.getMarketLabel();
		
		MarketStore store = this.getMarketStore(marketLabel);
		store.notifyMarketImageChange(change);
	}
	
	private MarketStore getMarketStore(String marketLabel) {
		MarketStore store = markets.get(marketLabel);
		if(store == null) {
			store = new MarketStore(marketLabel);
			this.markets.put(marketLabel, store);
		}
		
		return store;
	}
}
